const axios = require("axios")

module.exports = async ({ url = "", method = "GET", data = {} }) => {
    return new Promise(async (resolve) => {
        const axiosConfig = { url, method }

        axiosConfig[method == "GET" ? "params" : "data"] = data

        try {
            let { data } = await axios(axiosConfig)
            resolve(data)
        }
        catch (e) {
            console.log(e)
        }

    })
}